import com.adobe.cairngorm.control.CairngormEventDispatcher;
        	import net.optix.ip.events.AddPractitionerEvent;
        	import net.optix.ip.vo.PractitionerVO; 
        	import net.optix.ip.model.ModelLocator;
        	
            import mx.events.CloseEvent; 
            import mx.managers.PopUpManager;
            import mx.events.ValidationResultEvent;
            
            [Bindable]
            public var model:ModelLocator	=	ModelLocator.getInstance(); 
  			
  			[Bindable]
  			private var messageP:String	=	
  				'Welcome to IP Manager.\n\n'+
  				'You are registered to access the IP Manager site for '+model.firm.name+'.\n\n'+
  				'This email address is your userid.  Login here using your email address as the password.';
  			
  			public function init():void
  			{
  				model.bSubmit	=	true;
  				model.result	=	"";
  				model.close		=	"no";	
  			}
  			
            private function titleWindow_close(evt:CloseEvent):void { 
                model.result	=	"";
                PopUpManager.removePopUp(this); 
            }
            
            public function addPractitioner():void
            {	
            	var result:Boolean	=	true;

				var resultValidate:ValidationResultEvent;
				
				resultFirstName.text	=	"";
				resultLastName.text		=	"";
				resultEmail.text		=	"";
				
				model.result			=	"";
				
				resultValidate	=	stringValidator.validate(firstName.text);
            	if(resultValidate.type == ValidationResultEvent.INVALID)
            	{
            		result	=	false;
            		resultFirstName.text	=	
            			resultValidate.message;
            	}
            	
            	resultValidate	=	stringValidator.validate(lastName.text);
            	if(resultValidate.type == ValidationResultEvent.INVALID)
            	{
            		result	=	false;
            		resultLastName.text	=	
            			resultValidate.message;
            	}
            	
            	resultValidate	=	emailValidator.validate(email.text);
            	if(resultValidate.type == ValidationResultEvent.INVALID)
            	{
            		result	=	false;
            		resultEmail.text	=	
            			resultValidate.message;
            	}
            	
            	model.bSubmit	=	false;
            	model.result	=	"";
            	
            	
            	
            	if(result == true)
            	{
            		var vo:PractitionerVO = new PractitionerVO();
            		vo.firmID		=	model.firm.firmID;
            		vo.firstName	=	firstName.text;
            		vo.lastName		=	lastName.text;
            		vo.email		=	email.text;
            		vo.message		=	message.text;
            		
            		vo.bAttorney	=	bAttorney.selected?1:0;
            		vo.bDraftsMan	=	bDraftsman.selected?1:0;
            		vo.bEditor		=	bEditor.selected?1:0;
            		vo.bPatentBar	=	bPatentBar.selected?1:0;

            		var event:AddPractitionerEvent	=	new AddPractitionerEvent(vo);
            		CairngormEventDispatcher.getInstance().dispatchEvent( event );
            	}
            	else
            	{
            		model.bSubmit	=	true;
            	}
            }
            
            public function clear():void
            {
            	
            }